<?php
require_once '../config/config.php';
require_once 'inc/session.php';

$menu = 0;

if (isset($_POST['submit'])) {
    $sql = 'UPDATE admin SET nom = "' . $_POST["nom"] . '", prenom = "' . $_POST["prenom"] . '", login = "' . $_POST["login"] . '", password = "' . $_POST["password"] . '", email = "' . $_POST["email"] . '" WHERE id = ' . $_SESSION["admin_userid"];
    $req = mysql_query($sql) or die(mysql_error());

    $_SESSION["admin_username"] = $_POST["nom"] . " " . $_POST["prenom"];
    $_SESSION["admin_usermail"] = $_POST["email"];

    $message_succes = 'Mise à jour effectuée avec succès.';
}

$sql = 'SELECT * FROM admin WHERE id =' . $_SESSION["admin_userid"];
$req = mysql_query($sql) or die(mysql_error());
$res = mysql_fetch_array($req);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
        <meta http-equiv="X-UA-Compatible" content="IE=8" />
        <title>Interface Administration | L'essentiel du sup</title>
        <link rel="shortcut icon" href="images/favicon.ico" />
        <link rel="stylesheet" href="css/style.css" type="text/css" />
        <!--[if IE 9]>
            <link rel="stylesheet" media="screen" href="css/ie9.css"/>
        <![endif]-->
        <!--[if IE 8]>
            <link rel="stylesheet" media="screen" href="css/ie8.css"/>
        <![endif]-->
        <!--[if IE 7]>
            <link rel="stylesheet" media="screen" href="css/ie7.css"/>
        <![endif]-->
        <script type="text/javascript" src="js/plugins/jquery-1.7.min.js"></script>
        <script type="text/javascript" src="js/plugins/jquery.flot.min.js"></script>
        <script type="text/javascript" src="js/plugins/jquery.flot.resize.min.js"></script>
        <script type="text/javascript" src="js/plugins/jquery-ui-1.8.16.custom.min.js"></script>
        <script type="text/javascript" src="js/custom/general.js"></script>
        <script type="text/javascript" src="js/custom/dashboard.js"></script>
        <!--[if lt IE 9]>
                <script src="js/css3-mediaqueries.js"></script>
        <![endif]-->
    </head>
    <body class="loggedin">
        <?php include('inc/header.php') ?>
        <div class="mainwrapper">
            <div class="mainwrapperinner">
                <?php include('inc/menu.php') ?>
                <div class="maincontent noright">
                    <div class="maincontentinner">
                        <ul class="maintabmenu">
                            <li class="current">
                                <a>Parametres du compte</a>
                            </li>
                        </ul>
                        <div class="content">
                            <?php if (!empty($message_succes)) {
                                ?>
                                <div class="notification msgsuccess">
                                    <a class="close"></a>
                                    <p><?php echo $message_succes; ?></p>
                                </div>
                            <?php } ?>
                            <?php if (!empty($message_erreur)) {
                                ?>
                                <div class="notification msgerror">
                                    <a class="close"></a>
                                    <p><?php echo $message_erreur ?></p>
                                </div>
                            <?php } ?>
                            <div class="contenttitle">
                                <h2 class="form"><span>Modification du compte utilisateur</span></h2>
                            </div>
                            <form class="stdform stdform2" action="parametres_compte.php" method="post">
                                <p>
                                    <label>Nom</label>
                                    <span class="field">
                                        <input type="text" name="nom" class="smallinput" value="<?= $res["nom"] ?>" />
                                    </span>
                                </p>
                                <p>
                                    <label>Prénom</label>
                                    <span class="field">
                                        <input type="text" name="prenom" class="smallinput" value="<?= $res["prenom"] ?>" />
                                    </span>
                                </p>
                                <p>
                                    <label>E-mail</label>
                                    <span class="field">
                                        <input type="text" name="email" class="smallinput" value="<?= $res["email"] ?>" />
                                    </span>
                                </p>
                                <p>
                                    <label>Nom d'utilisateur</label>
                                    <span class="field">
                                        <input type="text" name="login" class="smallinput" value="<?= $res["login"] ?>" />
                                    </span>
                                </p>
                                <p>
                                    <label>Mot de passe</label>
                                    <span class="field">
                                        <input type="password" name="password" class="smallinput" value="<?= $res["password"] ?>" />
                                    </span>
                                </p>
                                <p class="stdformbutton">
                                    <button name="submit" class="submit radius2" type="submit">Enregistrer</button>
                                    <input type="reset" class="reset radius2" value="Annuler" />
                                </p>
                            </form>
                            <br clear="all" />
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </body>
</html>
